package cn.whuc.test

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Access_logDemo {
  def main(args: Array[String]): Unit = {
    // 1 创建sparkContext
    val sc: SparkContext = new SparkContext(
      new SparkConf()
        .setMaster("local[*]")
        .setAppName(" ")
    )

    // 2 编写代码
    val rdd1: RDD[String] = sc.textFile("input/access.log1")
    val rdd2: RDD[String] = rdd1.map(line => {
      val str: String = line.substring(1, line.length - 1)
      str.replaceAll("\"\u0001\"", "\u0001")
    })
    rdd2.collect().foreach(println)

    // 3 关闭上下文对象
    sc.stop()
  }
}
